home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-11-24 | 2.1 KB | 62 lines | [TEXT/GEOL] |
- Item forwarded by A33 to A34
-
- Item 3856820 22-Nov-89 05:57
-
- From: SW0075 SWV VTS Transportation Systems, GBG
-
- To: MACAPP.TECH$ MacApp Technical
-
- Sub: TList problems
-
- Hi all,
-
- We are having problem using TList for a large number of items.
-
- 1 - To insert kNumItems of myItem sequentially in a TList we tested the
- following source code:
-
- theListArr:=NewList;
- FOR theIndex:=1 TO kNumItems DO BEGIN
- New(myItem);
- theListArr.InsertLast(myItem);
- END;
-
- This solution is however very slow, probably because InsertLast has to move
- the already inserted items as well as add the 4 bytes necessary for the new
- item.
- Inserting 8000 items (of 30 bytes each) takes 58.4 seconds on my Macintosh
- IIcx.
-
- The performance may be improved by first making a Tlist of NIL-items and then
- inserting the real items according to the following source code :
-
- theListArr:=NewList;
- FOR theIndex:=1 TO kNumItems DO BEGIN
- theListArr.InsertLast(NIL);
- END;
-
- FOR theIndex:=1 TO kNumItems DO BEGIN
- New(myItem);
- theListArr.AtPut(theIndex,myItem);
- END;
-
- Now the performance is better, 2.8 seconds for the first loop and 3.3 seconds
- for the second. It seems odd that it takes almost as much time to initialize
- the TList to the required size as it takes to create and insert the items. I
- suggest that a new method is added to TList to initialize a list of a desired
- physical size. If there is a better solution to this problem please inform
- about.
-
- 2 - While testing the above issues, I notice that the program crashed while
- trying to InsertLast item number 8189 (which might be due to some use of
- Integers in the calculation of offsets in TList). This unfortunately restricts
- the use of TList to that number of Items. Is there a way to get round that
- restriction? I would be pleased if you removed this restriction, actually I
- would be even more pleased if you redefined the index in TList from Integer to
- Longint, 32767 is not a very high value in times of Virtual Memory !
-
- Bosse Ridderstolpe
- VTS
-
-
-